<template>
  <div class="box">
    <div class="back_top_img">
      <!--      <img :src="info.image" alt=""/>-->
      <img class="elImage" :src="baseUrl + info.image"/>
      <div class="title">
        <span class="el-icon-arrow-left" @click="$router.go(-1)"></span>
      </div>
    </div>
    <div class="backgroun">
      <div class="title">{{ info.title }}</div>
      <div class="lia_back_flex">
        <div>
          <div>{{ info.read_num }}</div>
          <div>{{ $t('阅读数') }}</div>
        </div>
        <div></div>
        <div>
          <div>{{ turnDatetime(info.create_time) }}</div>
          <div>Release date</div>
        </div>
      </div>
      <!--  -->
      <div class="centent_info">
        <!-- 内容 -->
        <!--        <div>-->
        <!--          <div class="card_title">-->
        <!--            <img src="../../../../assets/static/recharge/q4.png" alt=""/>-->
        <!--            <div>文章内容</div>-->
        <!--          </div>-->
        <!--&lt;!&ndash;          <div class="info_crad_list  info_crad_postion" v-html="info.content">&ndash;&gt;-->
        <!--&lt;!&ndash;            {{ info.content }}&ndash;&gt;-->
        <!--&lt;!&ndash;          </div>&ndash;&gt;-->
        <!--          <div class="info_crad_list  info_crad_postion" v-html="test">-->
        <!--          </div>-->
        <!--          <div class="info_crad_sun">-->
        <!--            <span>查看全部</span><span class="el-icon-arrow-down"></span>-->
        <!--          </div>-->
        <!--        </div>-->
        <!--  -->
        <div>
          <div class="card_title">
            <img src="../../../../assets/static/recharge/q4.png" alt=""/>
            <div>{{ $t('文章内容') }}</div>
          </div>
          <div :class="{'card-notall':!articaleVisiable}" class="info_crad_list info_crad_postion">
            <div v-html="info.content">每位用户仅可兑换10次
              The stores listed here are temporary closed:
              All Burger King in Airport Transit Area
              Valid for dine-in or takeaway use at all Burger
              KincOutlarst73 Aucust 2077
            </div>
            <!--            <div>每位用户仅可兑换10次-->
            <!--              The stores listed here are temporary closed:-->
            <!--              All Burger King in Airport Transit Area-->
            <!--              Valid for dine-in or takeaway use at all Burger-->
            <!--              KincOutlarst73 Aucust 2077-->
            <!--            </div>-->
            <div v-show="!articaleVisiable" class="info_crad_sun">
              <span @click="articaleVisiable=true">{{ $t('查看全部') }}</span><span class="el-icon-arrow-down"></span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {articleDetail} from '@/api/merbership/home'
import {newsdetail} from '@/api/merbership/level'
import {BASE_URL} from '@/config/api'

export default {
  data() {
    return {
      id: '',
      info: {},
      articaleVisiable: false
    }
  },
  computed: {
    baseUrl() {
      return BASE_URL.split('/api/')[0]
    }
  },
  activated() {
    this.id = this.$route.query.id
    this.newsdetail()
  },
  methods: {
    /**
     * 时间戳个数转化
     * @param timeStr
     * @returns {string}
     */
    turnDatetime(timeStr) {
      let time = new Date(Number(timeStr) * 1000)
      let year = time.getFullYear()
      let month = time.getMonth() + 1
      let date = time.getDate()
      let hours = time.getHours()
      let minute = time.getMinutes()
      let second = time.getSeconds()

      if (month < 10) {
        month = '0' + month
      }
      if (date < 10) {
        date = '0' + date
      }
      if (hours < 10) {
        hours = '0' + hours
      }
      if (minute < 10) {
        minute = '0' + minute
      }
      if (second < 10) {
        second = '0' + second
      }
      return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second
    },
    // ------------- axios ----------------
    /**
     * 新闻详情
     */
    newsdetail() {
      const pd = {
        id: this.id
      }
      newsdetail(this.$qs.stringify(pd))
        .then(res => {
          // this.$message.success(res.data.msg)
          this.info = res.data.data
          // console.log('imgURl', this.baseUrl + this.info.image)
        })
    },
    /**
     * 文章详情
     */
    articleDetail() {
      const pd = {
        id: this.id
      }
      articleDetail(pd)
        .then(res => {
          // this.$message.success(res.data.msg)
          this.info = res.data.data
          // console.log(this.baseUrl + this.info.image)
        })
    }
  }
}
</script>

<style scoped>
.box {
  background-color: #F5F5F5;
}

/* 背景图片 */
.back_top_img {
  width: 100%;
  background-color: #ffffff;
  /*background-image: url(../../../../assets/static/newsDetail/a2.png);*/
  /*background-repeat: no-repeat;*/
  /*background-size: 100%;*/
  height: 270px;
  /*padding-top: 15px;*/

}

.back_top_img > img {
  width: 100%;

  /*background-image: url(../../../../assets/static/newsDetail/a2.png);*/
  background-repeat: no-repeat;
  background-size: 100%;
  height: 270px;
}

.back_top_img > .elImage {
  width: 100%;
  /*background-image: url(../../../../assets/static/newsDetail/a2.png);*/
  background-repeat: no-repeat;
  background-size: 100%;
  height: 270px;
}

.back_top_img .title {
  position: absolute;
  top: 15px;
  color: #fff;
  font-size: 18px;
  padding: 15px;
  font-weight: bold;
  text-align: left;
  z-index: 10;
}

/* 内容 */
.backgroun {
  background-color: #F5F5F5;
  border-radius: 15px 15px 0 0;
  position: relative;
}

.title {
  height: 20px;
  padding: 20px;
  margin-top: -20px;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
}

/*  */
.lia_back_flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lia_back_flex > div {
  width: 50%;
  text-align: center;
}

.lia_back_flex > div:nth-child(2) {
  width: 1px;
  height: 20px;
  background-color: #ccc;
}

.lia_back_flex > div > div:nth-child(odd) {
  font-size: 14px;
  color: #333333;
  font-weight: bold;
}

.lia_back_flex > div > div:nth-child(even) {
  font-size: 12px;
  color: #999999;
  margin: 5px 0;
}

/*  */
.centent_info {
  margin: 15px;
}

/* card 标题 */
.card_title {
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: bold;
}

.card_title div {
  margin-left: 13px;
}

.card-notall {
  height: 72px;
}

.info_crad_list {
  /*height: 172px;*/
  overflow: hidden;
  padding: 10px;
  border-radius: 10px;
  background-color: #fff;
  margin: 10px 0;
  border: #CBCBCB solid 1px;
}

/* 条款 */
.info_crad_postion {
  position: relative;
}

.info_crad_sun {
  position: absolute;
  background-color: rgba(255, 255, 255, 0.8);
  width: 100%;
  left: 0;
  padding-top: 23px;
  text-align: center;
  color: #64BD1F;
  bottom: 0;
}

/*  */
.my_card {
  margin: 15px 0;
}

.my_card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fff;
  box-shadow: 0 3px 5px #ccc;
  padding: 10px;
  border-radius: 10px;
  font-size: 12px;
  margin: 10px 0;
}

.my_card img {
  width: 20px;
  margin-right: 10px;
}

.my_card > div > div:nth-child(1) {
  display: flex;
  align-items: center;
}

.dianhua {
  width: 12px;
  height: 12px;
}
</style>
